var t = new(require("../../../utils/http").HTTP);
Page({
  data: {
    xingenjin: "请选择",
    tname: !1,
    zhuti: [],
    checkedItem: "李秋建",
    checkedItems: "青澜实业"
  },
  onitemclick: function (e) {
    var a = this,
      n = a.data.zhuti[e.currentTarget.id].text;
    t.request({
      url: "https://www.qlsyyun.com:3000/reassignm",
      data: {
        bumen: n
      }
    }).then((function (t) {
      a.setData({
        bailey: t.data
      })
    }));
    var s = e.currentTarget.dataset.classify.text;
    a.setData({
      checkedItems: s
    })
  },
  quxiaos: function () {
    wx.navigateBack({
      delta: 1
    })
  },
  jnameclick: function (t) {
    var e = t.currentTarget.dataset.classify.jname;
    this.setData({
      checkedItem: e
    })
  },
  queren: function () {
    var t = this.data.checkedItem;
    this.setData({
      tname: !1,
      xingenjin: t
    })
  },
  opentname: function () {
    this.setData({
      tname: !0
    })
  },
  quxiao: function () {
    this.setData({
      tname: !1
    })
  },
  onLoad: function (e) {
    var a = this;
    t.request({
        url: "https://www.qlsyyun.com:3000/reassignment"
      }).then((function (t) {
        a.setData({
          zhuti: t.data
        })
      })),
      t.request({
        url: "https://www.qlsyyun.com:3000/reassignm",
        data: {
          bumen: "青澜实业"
        }
      }).then((function (t) {
        a.setData({
          bailey: t.data
        })
      })),
      t.request({
        url: "https://www.qlsyyun.com:3000/csjl",
        data: {
          bID: e.bID
        }
      }).then((function (t) {
        a.setData({
          list: t.data[0]
        })
      }));
    var n = wx.getStorageSync("user");
    a.setData({
      bID: e.bID,
      name: n
    })
  },
  formSubmit: function (e) {
    var a = this;
    wx.showModal({
      title: "提示",
      content: "请核对数据是否准确",
      success: function (e) {
        if (e.confirm)
          if ("请选择" != a.data.xingenjin) {
            var n = new Date(+new Date + 288e5).toJSON().substr(0, 19).replace("T", " "),
              s = n.slice(2, 4) + n.slice(5, 7) + 1;
            t.request({
              url: "https://www.qlsyyun.com:3000/section/zscb",
              header: {
                "Content-Type": "application/x-www-form-urlencoded"
              },
              method: "POST",
              data: {
                bID: a.data.bID,
                bm: a.data.name[1],
                zsy: a.data.xingenjin,
                tname: a.data.name[0]
              }
            }).then((function (e) {
              t.request({
                  url: "https://www.qlsyyun.com:3000/section/zsjd",
                  header: {
                    "Content-Type": "application/x-www-form-urlencoded"
                  },
                  method: "POST",
                  data: {
                    khbh: a.data.list.khbh,
                    qymc: a.data.list.qymc,
                    bm: a.data.checkedItems,
                    zsy: a.data.xingenjin,
                    khzbbh: s,
                    tname: a.data.name[0]
                  }
                }).then((function (t) {})),
                t.request({
                  url: "https://www.qlsyyun.com:3000/section/stjd",
                  header: {
                    "Content-Type": "application/x-www-form-urlencoded"
                  },
                  method: "POST",
                  data: {
                    khbh: a.data.list.khbh,
                    qymc: a.data.list.qymc,
                    bm: a.data.checkedItems,
                    zsy: a.data.xingenjin,
                    khzbbh: s,
                    tname: a.data.name[0],
                    bID: a.data.bID
                  }
                }).then((function (t) {})),
                t.request({
                  url: "https://www.qlsyyun.com:3000/section/stmx",
                  header: {
                    "Content-Type": "application/x-www-form-urlencoded"
                  },
                  method: "POST",
                  data: {
                    khbh: a.data.list.khbh,
                    qymc: a.data.list.qymc,
                    bm: a.data.checkedItems,
                    zsy: a.data.xingenjin,
                    tname: a.data.name[0],
                    bID: a.data.bID
                  }
                }).then((function (t) {
                  wx.showToast({
                    title: "公海池捞取成功",
                    icon: "none",
                    duration: 1e3,
                    mask: !0,
                    success: function () {
                      setTimeout((function () {
                        wx.navigateBack({
                          delta: 1
                        })
                      }), 1e3)
                    }
                  })
                }))
            }))
          } else
            wx.showToast({
              title: "请选择新负责招商员",
              icon: "none",
              duration: 1e3
            })
      }
    })
  }
});